/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package functions.web;

import com.google.gson.Gson;
import db.op.web.RegisterOP;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpSession;
import route.AbsFunction;

/**
 *
 * @author meluo
 */
public class Register extends AbsFunction{
private String userEmail;
private String password;

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String execute() {
        Map<String,Object> ret=new HashMap<>();
       RegisterOP regop=new RegisterOP(this);
       Map<String,Object> map=regop.op();
      if((boolean)map.get("status")){
          HttpSession session=getRequest().getSession();
          session.putValue("userKey",map.get("userKey"));
          ret.put("status", 0);
          ret.put("redir","appmanager.action");
      }else{
          ret.put("status",1);
          ret.put("message", "注册失败，确定是是否注册过");
      }
       Gson gson=new Gson();
       String s=gson.toJson(ret);
       System.out.println(s);
       regop.onDestroy();
       return s;
    }
        
        
        

 
    
}
